

#ifndef __BATT_GRADE_PRO_H_
#define __BATT_GRADE_PRO_H_
#include <stdint.h>
#include <stdbool.h>




#define BATT_NUM				8
#define BATT_BEGIN				0




typedef enum
{
    BAT_STP0_NULL,
    BAT_STP1_INIT,
    BAT_STP2_INIT,
    BAT_STP2_CHARGE,
    BAT_STP3_FULL,
    BAT_STP_MAX
} BatStepType;


typedef enum
{
    WH_Low,
    WH_Med,
    WH_High,
    WH_FULL,
    WH_MAX
} BattGrageType;


typedef enum
{
    COL_NULL    = 0x00,
    COL_RED     = 0x20,
    COL_YELLOW  = 0x24,
    COL_GREEN   = 0x04,
    COL_WHITD   = 0x25,
    COL_MAX
} GrageColourType;


typedef union
{
    uint8_t 		complete_in;


    struct
    {
        uint8_t 		bat1			: 1;
        uint8_t 		bat2			: 1;
        uint8_t 		bat3			: 1;
        uint8_t 		bat4			: 1;
        uint8_t 		bat5			: 1;
        uint8_t 		bat6			: 1;
        uint8_t 		bat7			: 1;
        uint8_t 		bat8			: 1;
    } c_bit;


//	  uint8_t put_in;
//	  struct
//	  {
//		  uint8_t bat1: 1;
//		  uint8_t bat2: 1;
//		  uint8_t bat3: 1;
//		  uint8_t bat4: 1;
//		  uint8_t bat5: 1;
//		  uint8_t bat6: 1;
//		  uint8_t bat7: 1;
//		  uint8_t bat8: 1;
//	  }put_in_byte;
} BATCOMPLEype;


typedef union
{
    uint8_t 		put_in;


    struct
    {
        uint8_t 		bat1			: 1;
        uint8_t 		bat2			: 1;
        uint8_t 		bat3			: 1;
        uint8_t 		bat4			: 1;
        uint8_t 		bat5			: 1;
        uint8_t 		bat6			: 1;
        uint8_t 		bat7			: 1;
        uint8_t 		bat8			: 1;
    } put_in_byte;


} BATPUTINType;


typedef union
{
    uint8_t 		byte;


    struct
    {
        uint8_t 		b0				: 1;
        uint8_t 		b1				: 1;
        uint8_t 		b2				: 1;
        uint8_t 		b3				: 1;
        uint8_t 		b4				: 1;
        uint8_t 		b5				: 1;
        uint8_t 		b6				: 1;
        uint8_t 		b7				: 1;
    } bits;


} ByteType;


typedef union
{
    uint16_t		flag_time;


    struct
    {
        uint8_t 		time;
        ByteType		flagbits;

    } byte;


} ShowTimeType;


typedef struct
{
    BATCOMPLEype	batt;
    BATPUTINType	batt_putin;
    uint8_t 		sgm415xx_stat[8];
    uint8_t 		bat_state[8];
    uint16_t		batt_CY[8];
    int 			batt_temp[8];
    uint8_t 		temp_state[8];
    BattGrageType	batt_grade[8];
    uint8_t 		batt_stop[8];
    bool			bad_charge[8];
    uint8_t         bad_charge_time[8];
} BATType;


extern BATType	BATT;




int batt_grade_init(uint8_t chal);
void batt_check(void);
void batt_thread_pro(void);
void batt_charge_management(void);
void dec_reset_sgm415xx_time(void);

#endif



